fix(backend): Handle missing content in streaming delta #316
+1
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a
KeyError: 'content'
that occurs when processing streaming chat completions.Details
When using the
chat_completions
endpoint withstream=True
, the finaldelta
chunk sent by the server may not contain acontent
key. This is part of the standard API behavior to signal the end of the stream.The existing code in
_extract_completions_delta_content
did not account for this possibility and tried to accessdelta['content']
directly, leading to aKeyError
and causing the benchmark process to crash when the stream ended.Test Plan
This was discovered while running
guidellm benchmark
against an OpenAI-compatible API endpoint (vialitellm
) that correctly implements the streaming protocol.guidellm benchmark
--target "http://10.64.1.62:4000/v1"
--model "qwen3-06b-2"
--processor "Qwen/Qwen3-0.6B"
--rate-type "synchronous"
--max-requests 1
--data "prompt_tokens=32,output_tokens=32,samples=1"
Related Issues
#315
Use of AI
## WRITTEN BY AI ##
)